Load and plot snRNA-seq data

seu = load_snrna_viseum(nfeatures = 5000, M3Drop_threshold = 0.1, emptyDrops_fdr_p_val = 0.01, scrublet_score = 1,
                        dir10x = c("filtered_feature_bc_matrix"))
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 27 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 27 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 29 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 29 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 31 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 25 rows containing missing values (geom_bar).

## [1] "Removing  0 undetected genes."

## NULL
## snapshotDate(): 2019-05-02
## downloading 0 resources
## loading from cache 
##     'AH70573 : 77319'

## Centering and scaling data matrix
## PC_ 1 
## Positive:  ENSMUSG00000025551, ENSMUSG00000021268, ENSMUSG00000041014, ENSMUSG00000060924, ENSMUSG00000079157 
## Negative:  ENSMUSG00000062078, ENSMUSG00000031425, ENSMUSG00000032841, ENSMUSG00000033740, ENSMUSG00000041607 
## PC_ 2 
## Positive:  ENSMUSG00000069670, ENSMUSG00000037996, ENSMUSG00000026109, ENSMUSG00000028399, ENSMUSG00000027674 
## Negative:  ENSMUSG00000007097, ENSMUSG00000022112, ENSMUSG00000014361, ENSMUSG00000039835, ENSMUSG00000048960 
## PC_ 3 
## Positive:  ENSMUSG00000026288, ENSMUSG00000035697, ENSMUSG00000020709, ENSMUSG00000052085, ENSMUSG00000048163 
## Negative:  ENSMUSG00000021010, ENSMUSG00000007097, ENSMUSG00000022112, ENSMUSG00000028517, ENSMUSG00000039835 
## PC_ 4 
## Positive:  ENSMUSG00000039607, ENSMUSG00000020042, ENSMUSG00000027985, ENSMUSG00000050315, ENSMUSG00000075316 
## Negative:  ENSMUSG00000054728, ENSMUSG00000022237, ENSMUSG00000025372, ENSMUSG00000026090, ENSMUSG00000074968 
## PC_ 5 
## Positive:  ENSMUSG00000027985, ENSMUSG00000038764, ENSMUSG00000050315, ENSMUSG00000021948, ENSMUSG00000048332 
## Negative:  ENSMUSG00000055761, ENSMUSG00000053519, ENSMUSG00000110246, ENSMUSG00000031559, ENSMUSG00000059493

## Computing nearest neighbor graph
## Computing SNN
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 44418
## Number of edges: 2014276
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8784
## Number of communities: 87
## Elapsed time: 12 seconds
## 09:06:17 Read 44418 rows and found 75 numeric columns
## 09:06:17 Using Annoy for neighbor search, n_neighbors = 30
## 09:06:17 Building Annoy index with metric = cosine, n_trees = 50
## 0%   10   20   30   40   50   60   70   80   90   100%
## [----|----|----|----|----|----|----|----|----|----|
## **************************************************|
## 09:06:28 Writing NN index file to temp file /tmp/Rtmpwpt6jn/file1dfb31616635
## 09:06:28 Searching Annoy index using 1 thread, search_k = 3000
## 09:06:49 Annoy recall = 100%
## 09:06:52 Commencing smooth kNN distance calibration using 1 thread
## 09:06:59 Initializing from normalized Laplacian + noise
## 09:07:06 Commencing optimization for 200 epochs, with 2031356 positive edges
## 09:07:58 Optimization finished

seu = FindClusters(seu, resolution = 0.1, n.start = 10)
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 44418
## Number of edges: 2014276
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.9871
## Number of communities: 31
## Elapsed time: 9 seconds
point_size=0.1
# show cells 
p1 = DimPlot(seu, reduction = "umap", pt.size = point_size, group.by = "RNA_snn_res.0.1") +
  ggtitle(label = "seurat_clusters")

p2 = DimPlot(seu, reduction = "umap", pt.size = point_size, group.by = "sample") +
  ggtitle(label = "sample")

p3 = FeaturePlot(seu, features = c("nCount_RNA"),
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "nUMI") +
  scale_colour_viridis_c(trans = "log10", option = "magma",
                         breaks = c(500, 1000, 10000, 100000), labels = c("500", "1k", "10k", "100k"))
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
p4 = FeaturePlot(seu, features = c("nFeature_RNA"),
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "nGenes") +
  scale_colour_viridis_c(trans = "log10", option = "magma",
                         breaks = c(200, 500, 1000, 2000, 5000, 8000), labels = c("200", "500", "1k", "2k", "5k", "8k"))
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
p5 = FeaturePlot(seu, features = c("ENSMUSG00000070570"),
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "Slc17a7 - Vesicular glutamate transporter 1")  +
  scale_colour_distiller(trans = "log10", palette = "RdPu")
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
cowplot::plot_grid(plotlist = list(p1, p2, p3, p4, p5), ncol = 4, align = "hv")
## Warning: Transformation introduced infinite values in discrete y-axis

Load and plot Zeisel data for matching regions

Matching regions include:

Amygdala, Hippocampus, Hypothalamus, MiddleCortex, Striatum, Thalamus

zeisel = load_zeisel(regions = c('Amygd', 'CA1', 'HC', 'Hypoth', 'Ctx2', 'SScortex', 'StriatVent', 'StriatDor', 'Thal'),
                  data_dir = "./data/mouse_zeisel/")
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 27 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 33 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 30 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 29 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 28 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 27 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 30 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 30 rows containing missing values (geom_bar).
## Warning: Transformation introduced infinite values in continuous y-axis
## Warning: Removed 29 rows containing missing values (geom_bar).

## [1] "Removing  0 undetected genes."

## NULL
## snapshotDate(): 2019-05-02
## downloading 0 resources
## loading from cache 
##     'AH70572 : 77318'
## Warning in SingleExIPlot(type = type, data = data[, x, drop = FALSE],
## idents = idents, : All cells have the same value of percent.mt.
## Warning in SingleExIPlot(type = type, data = data[, x, drop = FALSE],
## idents = idents, : All cells have the same value of nucl_mito_genes.

## Centering and scaling data matrix
## PC_ 1 
## Positive:  ENSMUSG00000021268, ENSMUSG00000044349, ENSMUSG00000026576, ENSMUSG00000021087, ENSMUSG00000035864 
## Negative:  ENSMUSG00000062078, ENSMUSG00000029622, ENSMUSG00000037706, ENSMUSG00000029723, ENSMUSG00000074457 
## PC_ 2 
## Positive:  ENSMUSG00000037625, ENSMUSG00000036634, ENSMUSG00000076439, ENSMUSG00000032854, ENSMUSG00000027858 
## Negative:  ENSMUSG00000041378, ENSMUSG00000018593, ENSMUSG00000029648, ENSMUSG00000079018, ENSMUSG00000036256 
## PC_ 3 
## Positive:  ENSMUSG00000041378, ENSMUSG00000029648, ENSMUSG00000079018, ENSMUSG00000036256, ENSMUSG00000030413 
## Negative:  ENSMUSG00000036887, ENSMUSG00000036905, ENSMUSG00000036896, ENSMUSG00000030579, ENSMUSG00000038642 
## PC_ 4 
## Positive:  ENSMUSG00000036887, ENSMUSG00000036905, ENSMUSG00000036896, ENSMUSG00000030579, ENSMUSG00000038642 
## Negative:  ENSMUSG00000017390, ENSMUSG00000022037, ENSMUSG00000050953, ENSMUSG00000020591, ENSMUSG00000028517 
## PC_ 5 
## Positive:  ENSMUSG00000055430, ENSMUSG00000001988, ENSMUSG00000028832, ENSMUSG00000049866, ENSMUSG00000033061 
## Negative:  ENSMUSG00000032503, ENSMUSG00000053310, ENSMUSG00000046215, ENSMUSG00000048644, ENSMUSG00000061718

## Computing nearest neighbor graph
## Computing SNN
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 52572
## Number of edges: 2541260
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.9114
## Number of communities: 86
## Elapsed time: 12 seconds
## 09:21:22 Read 52572 rows and found 75 numeric columns
## 09:21:22 Using Annoy for neighbor search, n_neighbors = 30
## 09:21:22 Building Annoy index with metric = cosine, n_trees = 50
## 0%   10   20   30   40   50   60   70   80   90   100%
## [----|----|----|----|----|----|----|----|----|----|
## **************************************************|
## 09:21:35 Writing NN index file to temp file /tmp/Rtmpwpt6jn/file1dfb1df44f0f
## 09:21:35 Searching Annoy index using 1 thread, search_k = 3000
## 09:21:55 Annoy recall = 100%
## 09:21:58 Commencing smooth kNN distance calibration using 1 thread
## 09:22:05 Initializing from normalized Laplacian + noise
## 09:22:16 Commencing optimization for 200 epochs, with 2422702 positive edges
## 09:23:19 Optimization finished
## Warning in FeaturePlot(seu, reduction = "umap", pt.size = 0.1, features =
## "percent.mt"): All cells have the same value (0) of percent.mt.

point_size=0.1
# show cells 
p1 = DimPlot(zeisel, reduction = "umap", pt.size = point_size, group.by = "Class") +
  ggtitle(label = "Annotation")

p2 = DimPlot(zeisel, reduction = "umap", pt.size = point_size, group.by = "Tissue") +
  ggtitle(label = "Tissue")

p3 = FeaturePlot(zeisel, features = c("nCount_RNA"),
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "nUMI") +
  scale_colour_viridis_c(trans = "log10", option = "magma",
                         breaks = c(500, 1000, 10000, 100000), labels = c("500", "1k", "10k", "100k"))
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
p4 = FeaturePlot(zeisel, features = c("nFeature_RNA"),
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "nGenes") +
  scale_colour_viridis_c(trans = "log10", option = "magma",
                         breaks = c(200, 500, 1000, 2000, 5000, 8000), labels = c("200", "500", "1k", "2k", "5k", "8k"))
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
p5 = FeaturePlot(zeisel, features = c("ENSMUSG00000070570"),
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "Slc17a7 - Vesicular glutamate transporter 1")  +
  scale_colour_distiller(trans = "log10", palette = "RdPu")
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
cowplot::plot_grid(plotlist = list(p1, p2, p3, p4, p5), ncol = 4, align = "hv")
## Warning: Transformation introduced infinite values in discrete y-axis

Plot some gene pairs

Combine with Zeisel data using Seurat CCA

I follow the default pipeline in https://satijalab.org/seurat/v3.0/integration.html.

anchors = FindIntegrationAnchors(object.list = list(seu, zeisel),
                                 dims = 1:50)
## Computing 2000 integration features
## Scaling features for provided objects
## Finding all pairwise anchors
## Running CCA
## Merging objects
## Finding neighborhoods
## Finding anchors
##  Found 38582 anchors
## Filtering anchors
##  Retained 8434 anchors
## Extracting within-dataset neighbors
integrated = IntegrateData(anchorset = anchors, 
                           k.weight = 50, dims = 1:50)
## Merging dataset 1 into 2
## Extracting anchors for merged samples
## Finding integration vectors
## Finding integration vector weights
## Integrating data
# normalised and PCA-project data
# switch to integrated assay. The variable features of this assay are automatically
# set during IntegrateData
DefaultAssay(integrated) = "integrated"

# Run the standard workflow for visualization and clustering
integrated = ScaleData(integrated, verbose = FALSE)
integrated = RunPCA(integrated, npcs = 50, verbose = FALSE)
integrated = RunUMAP(integrated, reduction = "pca", dims = 1:50)
## 12:19:33 Read 96990 rows and found 50 numeric columns
## 12:19:33 Using Annoy for neighbor search, n_neighbors = 30
## 12:19:33 Building Annoy index with metric = cosine, n_trees = 50
## 0%   10   20   30   40   50   60   70   80   90   100%
## [----|----|----|----|----|----|----|----|----|----|
## **************************************************|
## 12:19:54 Writing NN index file to temp file /tmp/Rtmpwpt6jn/file1dfb2fd38a5f
## 12:19:54 Searching Annoy index using 1 thread, search_k = 3000
## 12:20:37 Annoy recall = 100%
## 12:20:39 Commencing smooth kNN distance calibration using 1 thread
## 12:20:48 Initializing from normalized Laplacian + noise
## 12:21:18 Commencing optimization for 200 epochs, with 4649642 positive edges
## 12:23:18 Optimization finished
integrated$source = NA
integrated$source[!is.na(integrated$Class)] = "Zeisel"
integrated$source[!is.na(integrated$RNA_snn_res.0.1)] = "snRNA-seq Viseum"

ref_annot = paste0(integrated$Tissue,"_", integrated$Class)
ref_annot[ref_annot == "NANA"] = NA
integrated$ref_annot = ref_annot
integrated = FindNeighbors(integrated, reduction = "pca", dims = 1:50)
## Computing nearest neighbor graph
## Computing SNN
integrated = FindClusters(integrated, resolution = 0.11, n.start = 10)
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 96990
## Number of edges: 4963680
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.9894
## Number of communities: 28
## Elapsed time: 33 seconds
table(Zeisel_annotations = integrated$Class, new_annot = integrated$integrated_snn_res.0.11, 
      Tissue = integrated$Tissue, useNA = "ifany")
## , , Tissue = Amygd
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0   476     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   235     0
##         Neurons        0     1   170   970    10   109     0     0  1231
##         Oligos       158     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     1     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     2     0     0     0     0
##         Neurons        1     3   100     0     0    62     0     1     0
##         Oligos         0     0     0     0     0     0    38     8     0
##         Vascular       0     0     0     0   114     1     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     2     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0    29    10     0
##         Immune         0   108     0     0     0     0     0     0     0
##         Neurons        1     0     0     0     0     0     0     2    27
##         Oligos         1     0     0     0     0     0     0     0     0
##         Vascular     128     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = CA1
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0    90     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0    23     0
##         Neurons        0     0    42     0     2  3323     0     0     4
##         Oligos       133     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0     0     0
##         Neurons      325     3  1428    28     0    15     0     0     0
##         Oligos         0     0     0     0     0     0    25    18     0
##         Vascular       0     0     0     0   111     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     1     0     0
##         Immune         0    17     0     0     0     0     0     0     0
##         Neurons        0     0     0     0     0     0     0     8     0
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular      19     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = Ctx2
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0   905     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   310     0
##         Neurons        0     0     5     0  1048   288     0     0   222
##         Oligos       220     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     3     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     4     0     0     0     0
##         Neurons       95     0   122   688     0     0     0     0     0
##         Oligos         0     0     0     0     0     0    43    12     0
##         Vascular       0     0     0     0   316     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0    63     0     0     0     0     0     0     0
##         Neurons        0     0     0     0     0   130     0     0     0
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular      48     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = HC
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0  1707     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   300     0
##         Neurons        0     2     4     2     2   124     0     0    65
##         Oligos       358     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     4     0     0     2     1     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0     0     0
##         Neurons     2024  2051    32    34     2   785     0     4     0
##         Oligos         0     0     0     0     0     0   155    79     0
##         Vascular       0     0     0     0   255     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     1     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0    21     0     0
##         Immune         0    83     0     0     0     0     0     0     0
##         Neurons        2     0     0     0     0     0     1    89     0
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular      70     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = Hypoth
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0   974     0     0     0     0     0     0     0
##         Ependymal      0     3     1     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   256     0
##         Neurons        0     2  2130     2     0     0    37     0     0
##         Oligos       794     0     1     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     3     0     0     0     0
##         Ependymal      0     0     0     0     0     1     0     0     0
##         Immune         0     0     0     0     0     0     0     0     0
##         Neurons        0     0     4     0     5     0     0     0     0
##         Oligos         0     0     0     0     0     0   358    50     0
##         Vascular       0     0     0     0   376     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0    63     5     0
##         Immune         0   128     0     0     0     0     0     0     0
##         Neurons        0     0    34     0     1     0     0     0   124
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular     132     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = SScortex
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0   144     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   215     0
##         Neurons        0     0     1     0   862    43     0     0     2
##         Oligos       208     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     3     0     0     0     0
##         Neurons        5     0     3   147     1     0     0     0     0
##         Oligos         0     0     0     0     0     0    41    59     0
##         Vascular       0     0     0     0   309     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0    57     0     0     0     0     0     0     0
##         Neurons        1     0     0     0     0    16     0     0     0
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular     146     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = StriatDor
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0   668     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   337     0
##         Neurons        0     1    74  1926     0     1     0     0     0
##         Oligos       541     0     0     1     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     0     3     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0     0     0
##         Neurons        0     0    91     0     1   429     0     0     0
##         Oligos         0     0     0     0     0     0    63    66     0
##         Vascular       0     0     0     0   174     1     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0    67     0     0
##         Immune         0    59     0     0     0     0     0     0     0
##         Neurons        0     0     0     0     0     0     0     0    20
##         Oligos         1     0     0     0     0     0     0     0     0
##         Vascular      69     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = StriatVent
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0   775     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   430     0
##         Neurons        0     3  1471  2805    92    12     0     1   133
##         Oligos       511     1     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     0     2     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     1     0     0     0     0
##         Neurons        5     0    55    42    12   471     0     4     0
##         Oligos         0     0     0     0     0     0    98    42     0
##         Vascular       0     0     0     0   231     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0    67     0     0
##         Immune         0    80     0     0     0     0     0     0     0
##         Neurons        1     0     3     0     0    13     0     2    62
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular      87     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = Thal
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0   942     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0   300     0
##         Neurons        0     0   751     0     0     0  2306     0     0
##         Oligos      3167     1     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     2     4     0     0     0
##         Neurons        0     0     1     0     6     0     0     2     0
##         Oligos         0     0     0     0     0     0   612   156     0
##         Vascular       0     0     0     0   785     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     2     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0    76    48     0
##         Immune         0   165     0     0     0     0     0     0     0
##         Neurons        0     0   467   208    98     0     1     7     0
##         Oligos         2     0     0     0     0     0     0     0     0
##         Vascular     216     0     0     0     0     0     0     0     0
##         <NA>           0     0     0     0     0     0     0     0     0
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>           0
## 
## , , Tissue = NA
## 
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0     0     0
##         Neurons        0     0     0     0     0     0     0     0     0
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>       11792  3228  4079  1873  4165   981  2132  1855  2566
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0     0     0
##         Neurons        0     0     0     0     0     0     0     0     0
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>        1545  1663  1490  2207    73   389   328  1053  1047
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     0     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0     0     0
##         Neurons        0     0     0     0     0     0     0     0     0
##         Oligos         0     0     0     0     0     0     0     0     0
##         Vascular       0     0     0     0     0     0     0     0     0
##         <NA>          60    69   233   481   454   309     4   121    12
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>         209
table(Zeisel_annotations = integrated$Class, new_annot = integrated$integrated_snn_res.0.11,
      useNA = "ifany")
##                   new_annot
## Zeisel_annotations     0     1     2     3     4     5     6     7     8
##         Astrocytes     0  6681     0     0     0     0     0     0     0
##         Ependymal      0     3     1     0     0     0     0     0     0
##         Immune         0     0     0     0     0     0     0  2406     0
##         Neurons        0     9  4648  5705  2016  3900  2343     1  1657
##         Oligos      6090     2     1     1     0     0     0     0     0
##         Vascular       0     0     0     1     0     0     0     0     0
##         <NA>       11792  3228  4079  1873  4165   981  2132  1855  2566
##                   new_annot
## Zeisel_annotations     9    10    11    12    13    14    15    16    17
##         Astrocytes     0     4     0     0     8     6     0     0     0
##         Ependymal      0     0     0     0     0     1     0     0     0
##         Immune         0     0     0     0    12     4     0     0     0
##         Neurons     2455  2057  1836   939    27  1762     0    11     0
##         Oligos         0     0     0     0     0     0  1433   490     0
##         Vascular       0     0     0     0  2671     2     0     0     0
##         <NA>        1545  1663  1490  2207    73   389   328  1053  1047
##                   new_annot
## Zeisel_annotations    18    19    20    21    22    23    24    25    26
##         Astrocytes     5     0     0     0     0     0     0     0     0
##         Ependymal      0     0     0     0     0     0   324    63     0
##         Immune         0   760     0     0     0     0     0     0     0
##         Neurons        5     0   504   208    99   159     2   108   233
##         Oligos         4     0     0     0     0     0     0     0     0
##         Vascular     915     0     0     0     0     0     0     0     0
##         <NA>          60    69   233   481   454   309     4   121    12
##                   new_annot
## Zeisel_annotations    27
##         Astrocytes     0
##         Ependymal      0
##         Immune         0
##         Neurons        0
##         Oligos         0
##         Vascular       0
##         <NA>         209
table(new_annot = integrated$integrated_snn_res.0.11, 
      Tissue = integrated$Tissue, useNA = "ifany")
##          Tissue
## new_annot Amygd   CA1  Ctx2    HC Hypoth SScortex StriatDor StriatVent
##        0    158   133   220   358    794      208       541        511
##        1    477    90   905  1709    979      144       669        779
##        2    170    42     5     4   2132        1        74       1471
##        3    971     0     0     2      2        0      1927       2805
##        4     10     2  1048     2      0      862         0         92
##        5    109  3323   288   124      0       43         1         12
##        6      0     0     0     0     37        0         0          0
##        7    235    23   310   300    256      215       337        431
##        8   1231     4   222    65      0        2         0        133
##        9      1   325    95  2024      0        5         0          5
##        10     3     3     0  2055      0        0         0          0
##        11   100  1428   122    32      4        3        91         55
##        12     0    28   688    34      0      147         0         42
##        13   116   111   323   259    384      313       175        244
##        14    63    15     0   786      1        0       433        473
##        15    38    25    43   155    358       41        63         98
##        16     9    18    12    83     50       59        66         46
##        17     0     0     0     0      0        0         0          0
##        18   132    19    48    73    132      147        70         88
##        19   108    17    63    83    128       57        59         80
##        20     0     0     0     0     34        0         0          3
##        21     0     0     0     0      0        0         0          0
##        22     0     0     0     0      1        0         0          0
##        23     0     0   130     0      0       16         0         13
##        24    29     1     0    22     63        0        67         67
##        25    12     8     0    89      5        0         0          2
##        26    27     0     0     0    124        0        20         62
##        27     0     0     0     0      0        0         0          0
##          Tissue
## new_annot  Thal  <NA>
##        0   3167 11792
##        1    943  3228
##        2    751  4079
##        3      0  1873
##        4      0  4165
##        5      0   981
##        6   2306  2132
##        7    300  1855
##        8      0  2566
##        9      0  1545
##        10     0  1663
##        11     1  1490
##        12     0  2207
##        13   793    73
##        14     4   389
##        15   612   328
##        16   158  1053
##        17     0  1047
##        18   220    60
##        19   165    69
##        20   467   233
##        21   208   481
##        22    98   454
##        23     0   309
##        24    77     4
##        25    55   121
##        26     0    12
##        27     0   209
saveRDS(integrated, "./data/mouse_viseum_snrna/zeisel_integrated.rds")
fwrite(as.data.table(integrated@meta.data), "./data/mouse_viseum_snrna/zeisel_integrated_meta.tsv", sep = "\t")
point_size=0.1
# show cells 
p1 = DimPlot(integrated, reduction = "umap", pt.size = point_size, order = TRUE, group.by = "source") +
  ggtitle(label = "source")
p2 = DimPlot(integrated, reduction = "umap", pt.size = point_size, order = TRUE, na.value = "grey90", group.by = "RNA_snn_res.0.1") +
  ggtitle(label = "seurat_clusters")
p7 = DimPlot(integrated, reduction = "umap", pt.size = point_size, order = TRUE, na.value = "grey90", group.by = "integrated_snn_res.0.11") +
  ggtitle(label = "seurat_clusters2")

p3 = DimPlot(integrated, reduction = "umap", pt.size = point_size, order = TRUE, na.value = "grey90", group.by = "Class") +
  ggtitle(label = "Zeisel annotations") 
p4 = DimPlot(integrated, reduction = "umap", pt.size = point_size, order = TRUE, na.value = "grey90", group.by = "Tissue") +
  ggtitle(label = "Zeisel  region") 

p5 = FeaturePlot(integrated, features = c("nCount_RNA"), order = TRUE,
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "nUMI") +
  scale_colour_viridis_c(trans = "log10", option = "magma",
                         breaks = c(500, 1000, 10000, 100000), labels = c("500", "1k", "10k", "100k"))
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
p6 = FeaturePlot(integrated, features = c("nFeature_RNA"), order = TRUE,
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "nGenes") +
  scale_colour_viridis_c(trans = "log10", option = "magma",
                         breaks = c(200, 500, 1000, 2000, 5000, 8000), labels = c("200", "500", "1k", "2k", "5k", "8k"))
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
p7 = FeaturePlot(integrated, features = c("ENSMUSG00000070570"), order = TRUE,
                 reduction = "umap", pt.size = point_size, slot = "counts") +
  ggtitle(label = "Slc17a7 - Vesicular glutamate transporter 1")  +
  scale_colour_distiller(trans = "log10", palette = "RdPu")
## Warning: Could not find ENSMUSG00000070570 in the default search locations,
## found in RNA assay instead
## Scale for 'colour' is already present. Adding another scale for
## 'colour', which will replace the existing scale.
cowplot::plot_grid(plotlist = list(p1, p2, p7, p3, p4, p5, p6, p7), ncol = 4, align = "hv")
## Warning: Transformation introduced infinite values in discrete y-axis
## Warning: Transformation introduced infinite values in discrete y-axis

Transfer cell labels

trans_anchors = FindTransferAnchors(reference = zeisel, query = seu, 
    dims = 1:50)

predictions = TransferData(anchorset = anchors, refdata = zeisel$ref_annot, 
    dims = 1:50)
seu = AddMetaData(seu, metadata = predictions)
cat = data.table(c("Cell source", "source"),
                 c("Zeisel annotations", "Class"),
                 c("snRNA-seq Viseum annotations", "annot"))

plot_markers(integrated, markers = my_neuro_markers, categ = cat,
             point_size = 0.3, slot = "data", # log scale here for comparability between datasets
             ncol = 6)